package cn.tonyqiu.wonuly.web.impl;

import java.util.ArrayList;
import java.util.List;

import org.gwtwidgets.server.spring.GWTSpringController;

import cn.tonyqiu.wonuly.client.rpc.WonulyService;
import cn.tonyqiu.wonuly.model.Bill;
import cn.tonyqiu.wonuly.model.User;
import cn.tonyqiu.wonuly.service.BillManager;
import cn.tonyqiu.wonuly.service.UserManager;
import cn.tonyqiu.wonuly.service.util.UserServiceUtil;
import cn.tonyqiu.wonuly.web.util.DateFormatter;

public class WonulyServiceImpl extends GWTSpringController implements
		WonulyService {

	/**
	 * 
	 */
	private static final long serialVersionUID = -435493685667402734L;

	private UserManager userManager;
	private BillManager billManager;

	/**
	 * @return the userManager
	 */
	public UserManager getUserManager() {
		return userManager;
	}

	/**
	 * @param userManager
	 *            the userManager to set
	 */
	public void setUserManager(UserManager userManager) {
		this.userManager = userManager;
	}

	@Override
	public String sayHi() throws Exception {
		// TODO Auto-generated method stub
		return "Hi";
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.tonyqiu.wonuly.client.rpc.WonulyService#getUsername()
	 */
	@Override
	public String getUsername() throws Exception {
		User user = userManager.getUserByEmail();
		if (user == null)
			throw new Exception("User doesn't exist!");
		return user.getName();
	}


	/**
	 * @return the billManager
	 */
	public BillManager getBillManager() {
		return billManager;
	}

	/**
	 * @param billManager
	 *            the billManager to set
	 */
	public void setBillManager(BillManager billManager) {
		this.billManager = billManager;
	}

}
